#include "Spring.h"
#include <GL\glut.h>

// a basic spring class to get the job done for this asignement
Spring::Spring(Vector3<float> s, Vector3<float> e, float constant):
	Start(s),
	End(e),
	_springConstant(constant)
{

}

	// the lenght of the spring
float Spring::Length()
{
	Vector3<float> len = End - Start;
	return len.Magnitude();
}

// gets the force that will be applied to from the start to the end
Vector3<float> Spring::getForce()
{
	//   vector direction & X  *   K    
	return (Start - End) * _springConstant;
}


// whooooo draw the line
void Spring::Draw()
{
	glBegin(GL_LINE_STRIP); 
	glColor3f(1, 1, 1);

	glVertex3f(Start.X(), Start.Y(), Start.Z());
	glVertex3f(End.X(), End.Y(), End.Z());

	glEnd();
	
}

